<html>
<head>
<link href="../../../Objects/sofa_white.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="contenu">
		
		<center><h3>Lighting (4/7)</h3>
		  <br><br>
		  <img src="3_Visual.png" name="Visu_start" align="middle" width=300>
		</center>

		
		<br><div id="orangeText">Description</div>
		<p> Next, we will see how to manage lights.</p>
        
		<div id="orangeText">Key points</div>
        
        
        
        <div id="tutorialAction">    
        <p>Clear the scene graph.</p>
        <p>Add a <strong>GNode</strong> to the <strong>root</strong> node and name it "Dragon".</p>
        <p>Add an <strong>OglModel</strong> to the <strong>Dragon</strong> node, and set the <strong>Path to the model</strong> to <strong>/Sofa/share/mesh/dragon.obj</strong>.</p></div>
        
		<p>By default, a (positional) light is present in the OpenGL Viewer, for those who do not want to mess with it.
		But if you want to tweak your scene, you may want to modify this light or add other lights.</p>
        
		<p>In order to do that, first you need to add a <b>LightManager</b>, without any kind of parameters
		(We will see later why we need it). After that, you can add up to the maximum number of lights permitted by OpenGL,
		which is 8 on most common systems.</p>
        
        <div id="tutorialAction"><p>Add a <strong>LightManager</strong> component to the <strong>root</strong> node. Rename it "lightManager".</p></div>
		
		<p>There are 3 kinds of lights in SOFA. They are basically the same as in OpenGL :
		<p>
        <ul>
		<li><b>PositionalLight</b> (main parameter : <i>position</i>) ;</li>
		<li><b>DirectionalLight</b> (main parameter : <i>direction</i>) ;</li>
		<li><b>SpotLight</b> (main parameters : <i>position</i> and <i>direction</i>) .</li>
		</ul>
        </p>
		<p><strong>color</strong> is a common parameter for all these 3 lights.</p>
		<p><b>SpotLight</b> has other non-essential parameters : <strong>cutoff</strong> and <strong>exponent</strong> (default value may suffice).</p>

		<div id="tutorialAction"><p>Add three <strong>Spotlight</strong> components to the <strong>root</strong> node. Name one "redLight", one "greenLight", and one "blueLight".</p>
        
        <p>In the <strong>redLight</strong>, set the <strong>color of the light</strong> to (1 0 0) and the <strong>position</strong> to (-5 -2.5 20).</p>
        <p>In the <strong>greenLight</strong>, set the <strong>color of the light</strong> to (0 1 0) and the <strong>position</strong> to (0 2.5 20).</p>
        <p>In the <strong>blueLight</strong>, set the <strong>color of the light</strong> to (0 0 1) and the <strong>position</strong> to (5 -2.5 20).</p>
        
        <p>Run in SOFA</p></div>
        
        <div id="orangeText">Note:</div>
        
		<p><b>LightManager</b> and <b>*Light</b> must be in the root node if you want your whole scene to be lighted.</p>
		
		
        <br><center><h3><a href="4_Visual.scn">Next</a></center></h3>
	</div>
</body>
</html>
